#!/bin/bash

# Do whatever needs to be done to prepare for SuperCollider and livecoding.
# Feel free to add support for additional platforms and setups...

if [[ $OSTYPE == "linux-gnu" ]]; then
  if pgrep "jackd" &>/dev/null; then
    echo "jackd already running..."
  else
    echo "Starting jack sound daemon..."
    pkill -9 pulseaudio
    qjackctl -s &

    puts "Starting pulseaudio in Jack mode..."
    pulseaudio -nF ~/.jack.pa --start
  fi

  if (( pgrep "java.*martiansoftware.nailgun" &>/dev/null )) && (( $EDITOR == "vim" )) ; then
    echo "vimclojure's nailgun server already running..."
    echo "killing nailgun..."
    pkill -9 "java.*martiansoftware.nailgun"
  fi

  echo "Starting the vimclojure nailgun server..."
  ./script/ng-server &
fi
